package com.atguigu.admin.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 *处理整个web controller 的异常
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    // 处理异常,推荐这种方式
    @ExceptionHandler({ArithmeticException.class,NullPointerException.class})
    public String handleArithException(Exception e){
        log.error("异常是: {}",e);

        return "login"; // 视图地址
    }

}
